<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>用户详情 - 权限管理系统</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css">
</head>
<body>
<div class="header">
    <div class="nav">
        <div class="nav-brand">权限管理系统</div>
        <ul class="nav-links">
            <li><a href="${pageContext.request.contextPath}/">首页</a></li>
            <li><a href="${pageContext.request.contextPath}/user/list">用户管理</a></li>
            <li><a href="${pageContext.request.contextPath}/role/list">角色管理</a></li>
            <li><a href="${pageContext.request.contextPath}/user/search">用户搜索</a></li>
        </ul>
    </div>
</div>

<div class="container">
    <div class="card">
        <h2>用户详情</h2>

        <c:if test="${not empty user}">
            <div class="user-info">
                <div class="info-item">
                    <label>用户ID</label>
                    <div>${user.id}</div>
                </div>
                <div class="info-item">
                    <label>登录名</label>
                    <div>${user.loginname}</div>
                </div>
                <div class="info-item">
                    <label>姓名</label>
                    <div>${user.name}</div>
                </div>
                <div class="info-item">
                    <label>邮箱</label>
                    <div>${user.email}</div>
                </div>
                <div class="info-item">
                    <label>手机号</label>
                    <div>${user.mobilephone}</div>
                </div>
                <div class="info-item">
                    <label>状态</label>
                    <div>
                            <span class="badge ${user.status == 0 ? 'badge-success' : 'badge-danger'}">
                                    ${user.status == 0 ? '正常' : '禁用'}
                            </span>
                    </div>
                </div>
            </div>

            <div class="card">
                <h3>角色列表</h3>
                <c:choose>
                    <c:when test="${not empty user.roles}">
                        <div class="role-list">
                            <c:forEach var="role" items="${user.roles}">
                                <div class="role-item">
                                        ${role.name} - ${role.description}
                                </div>
                            </c:forEach>
                        </div>
                    </c:when>
                    <c:otherwise>
                        <p>该用户暂无角色</p>
                    </c:otherwise>
                </c:choose>
            </div>
        </c:if>

        <c:if test="${empty user}">
            <p>用户不存在</p>
        </c:if>

        <a href="${pageContext.request.contextPath}/user/list" class="btn btn-primary">
            返回用户列表
        </a>
    </div>
</div>
</body>
</html>